//
//  CashierNewPopView.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/7.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "CashierNewPopView.h"
@interface CashierNewPopView()
{
    UIImageView *bgImageView;
    UIButton *quickCashBtn;
    UILabel *quickCashLineLabel;
    UIButton *unPayedOrderBtn;
    UILabel *unPayedOrderLineLabel;
    UIButton *historyOrderBtn;
    
    
}

@end
@implementation CashierNewPopView
-(instancetype)init
{
    self=[super init];
    if (self) {
        [self createUI];
        [self setAutoLayout];
    }
    return self;
}
-(void)createUI
{
    UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
    [self addGestureRecognizer:singleTap];
    
    bgImageView =[[UIImageView alloc] init];
//    [bgImageView setBackgroundColor:[UIColor colorWithRed:25.0/255.0 green:39.0/255.0 blue:5.0/255.0 alpha:0.88]];
    [bgImageView setImage:[UIImage imageNamed:@"tanchubeijing"]];
    
    [self addSubview:bgImageView];
    
    
    quickCashBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [quickCashBtn setTitle:@"快速收银" forState:UIControlStateNormal];
    [quickCashBtn addTarget:self action:@selector(quickCashBtnClick) forControlEvents:UIControlEventTouchUpInside];
    quickCashBtn.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [quickCashBtn setImage:[UIImage imageNamed:@"kuaisushouyin"] forState:UIControlStateNormal];
    quickCashBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//设置button的内容横向居中
    quickCashBtn.contentEdgeInsets=UIEdgeInsetsMake(0,15,0,0);
    [self addSubview:quickCashBtn];
    
    quickCashLineLabel=[[UILabel alloc] init];
    [quickCashLineLabel setBackgroundColor:[UIColor colorWithRed:48.0f/255.0f green:83.0f/255.0f blue:7.0f/255.0f alpha:1.0]];
    [self addSubview:quickCashLineLabel];
    
    
    unPayedOrderBtn=[UIButton buttonWithType:UIButtonTypeCustom];
   [unPayedOrderBtn setTitle:@"未付订单" forState:UIControlStateNormal];
    unPayedOrderBtn.titleLabel.font = [UIFont systemFontOfSize: 15.0];
   [unPayedOrderBtn addTarget:self action:@selector(unPayedOrderBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [unPayedOrderBtn setImage:[UIImage imageNamed:@"weifudingdan"] forState:UIControlStateNormal];
    unPayedOrderBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//设置button的内容横向居中
    unPayedOrderBtn.contentEdgeInsets=UIEdgeInsetsMake(0,15,0,0);
    [self addSubview:unPayedOrderBtn];
    
    unPayedOrderLineLabel=[[UILabel alloc] init];
    [unPayedOrderLineLabel setBackgroundColor:[UIColor colorWithRed:48.0f/255.0f green:83.0f/255.0f blue:7.0f/255.0f alpha:1.0]];
    [self addSubview:unPayedOrderLineLabel];
    
    historyOrderBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [historyOrderBtn setTitle:@"历史账单" forState:UIControlStateNormal];
    historyOrderBtn.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [historyOrderBtn addTarget:self action:@selector(historyOrderBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [historyOrderBtn setImage:[UIImage imageNamed:@"lishizhangdan"] forState:UIControlStateNormal];
    historyOrderBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//设置button的内容横向居中
    historyOrderBtn.contentEdgeInsets=UIEdgeInsetsMake(0,15,0,0);

    [self addSubview:historyOrderBtn];
    
}
-(void)quickCashBtnClick
{
    
    if ([self.delegate respondsToSelector:@selector(quickCashButtonClick)]) {
        [self.delegate quickCashButtonClick];
    }
   
[self removeFromSuperview];
}
-(void)unPayedOrderBtnClick
{
    
    if ([self.delegate respondsToSelector:@selector(unPayedOrderButtonClick)]) {
        [self.delegate unPayedOrderButtonClick];
    }
[self removeFromSuperview];
}
-(void)historyOrderBtnClick
{
    
    if ([self.delegate respondsToSelector:@selector(historyOrderButtonClick)]) {
        [self.delegate historyOrderButtonClick];
    }
[self removeFromSuperview];
}
-(void)handleSingleTap:(UITapGestureRecognizer *)sender
{
    [self removeFromSuperview];
}
- (void)show
{
    // 获得主窗口
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    self.frame= CGRectMake(0, 0, ScreenWidth, ScreenHeight);
    [window addSubview:self];
    
   
}
-(void)setAutoLayout
{
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@170);
        make.height.equalTo(@167);
        make.top.equalTo(self.mas_top).with.offset(60);
        make.right.equalTo(self.mas_right).with.offset(-8);
    }];
    [quickCashBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(bgImageView.mas_width);
//        make.right.equalTo(bgImageView.mas_right);
        make.centerX.equalTo(bgImageView.mas_centerX);
        make.top.equalTo(bgImageView.mas_top).with.offset(5);
        make.height.equalTo(bgImageView.mas_height).dividedBy(3);
    }];
    [quickCashLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgImageView.mas_left).with.offset(7);
        make.right.equalTo(bgImageView.mas_right).with.offset(-7);
        make.bottom.equalTo(quickCashBtn.mas_bottom);
        make.height.equalTo(@1);
    }];
    [unPayedOrderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(bgImageView.mas_width);
        //        make.right.equalTo(bgImageView.mas_right);
        make.centerX.equalTo(bgImageView.mas_centerX);

        make.top.equalTo(quickCashBtn.mas_bottom);
        make.height.equalTo(bgImageView.mas_height).dividedBy(3);
    }];
    [unPayedOrderLineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgImageView.mas_left).with.offset(7);
        make.right.equalTo(bgImageView.mas_right).with.offset(-7);
        make.bottom.equalTo(unPayedOrderBtn.mas_bottom);
        make.height.equalTo(@1);
    }];
    [historyOrderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(bgImageView.mas_width);
        //        make.right.equalTo(bgImageView.mas_right);
        make.centerX.equalTo(bgImageView.mas_centerX);

        make.top.equalTo(unPayedOrderBtn.mas_bottom);
        make.height.equalTo(bgImageView.mas_height).dividedBy(3);
    }];
   

}
@end
